import type { EfficiencyConfig, SaveEfficiencyParams } from '@/views/equipment-efficiency/type'

const controller = getAjaxBaseUrl('/equipmentEfficiency', '/energy')

/** 查询某一个设备的能效配置数据 */
export function queryEquipmentEfficiencyConfigData(equipmentId: number) {
  return get<{
    leftData: EfficiencyConfig[]
    rightData: EfficiencyConfig[]
    middleData: EfficiencyConfig[]
    downData: EfficiencyConfig[]
  }>(`${controller}/efficiencyData`, { equipmentId })
}

/** 保存设备的能效配置数据 */
export function saveEquipmentEfficiencyConfigData(data: SaveEfficiencyParams) {
  return post(`${controller}/save`, data)
}

/** 根据配置ID集，去查询能效数据 */
export function queryEquipmentEfficiencyDataByIds(ids: number[]) {
  return post<{ id: number, value: string, name: string }[]>(`${controller}/data`, ids)
}

/** 根据能效配置ID集，去查询时间段的数据曲线 */
export function queryEquipmentEfficiencyDataCurveByIds(ids: number[]) {
  return post<{ id: number, list: { time: string, value: string }[] }[]>(`${controller}/timeData`, ids)
}
